package com.fpost.form.dto;

import com.fpost.domain.ArticleComment;
import com.fpost.domain.User;
import com.fpost.helper.Byline;
import com.fpost.manager.UserManager;
import com.fpost.util.CommonUtils;
import com.fpost.util.DateUtil;

public class ArticleCommentDTO {
	
	private String articleCommentId;
	private String articleId;
	private String comment;
	private String createdOn;
	private String createdBy;
	private String createdIp;	
	
	private String firstName;
	private String lastName;
	private String username;
	
	private Byline byline;
	
	public ArticleCommentDTO() {
		super();
	}
	
	public ArticleCommentDTO(ArticleComment articleComment) {
		this.articleCommentId = String.valueOf(articleComment.getArticleCommentId());
		this.articleId = String.valueOf(articleComment.getArticle().getArticleId());
		this.comment = CommonUtils.replaceNewline(articleComment.getComment());
		this.createdOn = DateUtil.dateToString(articleComment.getCreatedOn(), DateUtil.COMPLEX_DATE_FORMAT_TIME_ZONE);
		this.createdBy = String.valueOf(articleComment.getCreatedBy());
		this.createdIp = CommonUtils.privateIpAddress(articleComment.getCreatedIp());
		
		User user = new UserManager().get(articleComment.getCreatedBy());
		this.firstName = user.getFirstName();
		this.lastName = user.getLastName();
		this.username = user.getUsername();
	}
	
	public String getArticleCommentId() {
		return articleCommentId;
	}

	public void setArticleCommentId(String articleCommentId) {
		this.articleCommentId = articleCommentId;
	}

	public String getArticleId() {
		return articleId;
	}

	public void setArticleId(String articleId) {
		this.articleId = articleId;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public String getCreatedOn() {
		return createdOn;
	}

	public void setCreatedOn(String createdOn) {
		this.createdOn = createdOn;
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public String getCreatedIp() {
		return createdIp;
	}

	public void setCreatedIp(String createdIp) {
		this.createdIp = createdIp;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	public Byline getByline() {
		return new Byline(this);
	}
	
}
